package com.xiongtian.springframework.context.support;

import com.xiongtian.springframework.beans.factory.support.DefaultListableBeanFactory;
import com.xiongtian.springframework.beans.factory.xml.XmlBeanDefinitionReader;

/**
 * @Author: xiongtian
 * @CreateTime: 2025-03-28  17:05
 * @Version: 1.0
 * @Description: 抽象的 XML 应用上下文
 */

public abstract class AbstractXmlApplicationContext extends AbstractRefreshableApplicationContext {

    /**
     * 加载 BeanDefinition
     *
     * @param beanFactory 注册器
     */
    @Override
    protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) {
        XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory, this);
        String[] configLocations = getConfigLocations();
        if (null != configLocations) {
            beanDefinitionReader.loadBeanDefinitions(configLocations);
        }
    }

    /**
     * 获取配置文件位置
     *
     * @return 配置文件位置
     */
    protected abstract String[] getConfigLocations();

}